|
|
|
|
|
|
|
After youve added this method to your Employee collection class, you need to perform one more step. Go to the Tools, Procedure Attributes menu item and select the Iterate() function from the drop-down list of names. Click the Advanced command button, and in the Procedure ID drop-down list, type in the value 4, as shown in Figure 22.6. |
|
|
|
|
|
|
|
|
Figure 22.6
The Procedure Attributes dialog box. |
|
|
|
|
|
|
|
|
This value is a special identifier that tells COM that this procedure ID is the iteration function that needs to be able to return the objects one by one from the collection. Now, via the Iterate 2 command button on the sample form, you can iterate through the collection using the For...Each Next construct: |
|
|
|
 |
|
|
|
|
Private Sub cmdIterate2_Click()
Dim oEmp As Employee
lstNames.Clear For Each oEmp In moEmps lstNames.AddItem oEmp.LastName & ", " & _
oEmp.FirstName
Next
End Sub |
|
|
|
|
|